﻿using BaiTu.Framework.MVCFramework.Descriptors;
using BaiTu.Framework.MVCFramework.Registrater;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BaiTu.Framework.MVCFramework.Factories
{
    class ControllerFactory
    {
        internal static ControllerDescriptor Resolve(System.Web.HttpContext context)
        {
            //根据传入的主文件名，得到相应的Controller Type
            string mainFileName = System.IO.Path.GetFileNameWithoutExtension(context.Request.Path);

            string key = string.Format("{0}controller", mainFileName);

            return ControllerRegistry.Resolve(key);
        }
    }
}
